//
//  XYMacroTest.m
//  JustForTest
//
//  Created by YaoZhaofeng on 16/4/14.
//  Copyright © 2016年 YaoZhaofeng. All rights reserved.
//

#import "XYMacroTest.h"

//#define MIN(A,B) A>B?B:A
//
//#define MIN(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })

#define __UNION__(A,B) A##B

#define MIN(A,B) __MIN_IMPL(A,B,__COUNTER__)

#define __MIN_IMPL(A,B,L) ({__typeof__(A) __UNION__(__a,L) = (A);\
                            __typeof__(B) __UNION__(__b,L) = (B);\
                            (__UNION__(__a,L)<__UNION__(__b,L)) ? __UNION__(__a,L) : __UNION__(__b,L)})

@implementation XYMacroTest

- (void)macroTest{
//#define __NSX_PASTE__(A,B) A##B
//    
//#define MIN(A,B) __NSMIN_IMPL__(A,B,__COUNTER__)
//    
//#define __NSMIN_IMPL__(A,B,L) ({ __typeof__(A) __NSX_PASTE__(__a,L) = (A); __typeof__(B) __NSX_PASTE__(__b,L) = (B); (__NSX_PASTE__(__a,L) < __NSX_PASTE__(__b,L)) ? __NSX_PASTE__(__a,L) : __NSX_PASTE__(__b,L); })
    
}

@end
